
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>忘记用户名</title>
		<link rel="stylesheet" type="text/css" href="../../Resours/css/Login.css"/>
		<link rel="stylesheet" type="text/css" href="../../Resours/css/bootstrap.min.css">
	</head>
	<body>
		<div id="login">
			<div id="login_center">
				<form class="form-horizontal">
					  <div class="form-group">
					    <label for="phone" class="col-sm-2 control-label">电话号码</label>
					    <div class="col-sm-10">
					      <input type="text" class="form-control"  placeholder="请输入电话号码"" name="phone" id="phone">
					    </div>
					  </div>
					  <div class="form-group">
					    <label for="pwd" class="col-sm-2 control-label">密码</label>
					    <div class="col-sm-10">
					      <input type="password" class="form-control"  placeholder="请输入密码" name="pwd" id="pwd">
					    </div>
					  </div>
					  <div class="form-group">
					    <label for="username" class="col-sm-2 control-label">新用户名</label>
					    <div class="col-sm-10">
					      <input type="text" class="form-control" name="username" id="username" placeholder="请输入新用户名">
					    </div>
					  </div>
					  <div class="form-group">
					    <div class="col-sm-offset-2 col-sm-10">
					      
					    </div>
					  </div>
					</form>
			<button id="submit"  class="btn btn-success btn-lg " onclick="submit()">修改</button>
			</div>
		</div>
	</body>
	<script type="text/javascript"
			src="../../Resours/js/jquery-3.3.1.min.js"></script>
		<script>
		//判断是否所选项为空
		function submit(){
				var username = $("#username").val();   
				var pwd = $("#pwd").val(); 
				var phone = $("#phone").val();
				
				if(pwd==="" && username==="" && phone ===""){
					alert('请输入信息');
				}else if(username===""){
					alert('请输入用户名');
				}else if(pwd===""){
					alert('请输入密码');
				}else if(phone===""){
					alert('请输入电话号码');
				}else{
					//进行ajax交互
					 $.ajax({
							method:'get',
							data:{'username': username,'pwd':pwd,"phone":phone},
							url:'/Shopx/UserServlet?action=lostname',
							success:function(data){
								if(data>0){
									alert('修改用户名成功，请使用新用户名登录');
									window.close();
									history.back();
								}else if(data===0){
									alert('修改用户名失败，请提交正确的信息');
								}
							},
							dataType:'json'
			            });
				}
		}
		</script>
</html>
